package org.huoran.sakamichi.main.controller;

import org.huoran.sakamichi.main.redis.RedisService;
import org.huoran.sakamichi.main.util.ResultBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;


@Controller
@RequestMapping({"/redis"})
public class RedisController {

    @Resource
    private RedisService redisService;

    @ResponseBody
    @RequestMapping(value = {"/set/{key}/{value}"})
    public ResultBean set(@PathVariable String key, @PathVariable String value) {
        return this.redisService.set(key, value);
    }

    @ResponseBody
    @RequestMapping(value = {"/get/{key}"})
    public ResultBean get(@PathVariable String key) {
        return this.redisService.get(key);
    }

    @ResponseBody
    @RequestMapping(value = {"/delete/{key}"})
    public ResultBean delete(@PathVariable String key) {
        return this.redisService.delete(key);
    }
}
